/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multiface.promonet.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author diego
 */
@Entity
@Table(name = "file")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
    @NamedQuery(name = "File.findByIdfile", query = "SELECT f FROM File f WHERE f.idfile = :idfile"),
    @NamedQuery(name = "File.findByData", query = "SELECT f FROM File f WHERE f.data = :data"),
    @NamedQuery(name = "File.findByCopertina", query = "SELECT f FROM File f WHERE f.copertina = :copertina"),
    @NamedQuery(name = "File.findBySize", query = "SELECT f FROM File f WHERE f.size = :size")})
public class File implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idfile")
    private Integer idfile;
    @Basic(optional = false)
    @Lob
    @Column(name = "bytes")
    private byte[] bytes;
    @Basic(optional = false)
    @Column(name = "data")
    @Temporal(TemporalType.TIMESTAMP)
    private Date data;
    @Basic(optional = false)
    @Column(name = "copertina")
    private boolean copertina;
    @Basic(optional = false)
    @Column(name = "size")
    private int size;
    @JoinColumn(name = "utente", referencedColumnName = "idutente")
    @ManyToOne
    private Utente utente;
    @JoinColumn(name = "report", referencedColumnName = "idreport")
    @ManyToOne
    private Report report;
    @JoinColumn(name = "mimetype", referencedColumnName = "idmimetype")
    @ManyToOne(optional = false)
    private Mimetype mimetype;

    public File() {
    }

    public File(Integer idfile) {
        this.idfile = idfile;
    }

    public File(Integer idfile, byte[] bytes, Date data, boolean copertina, int size) {
        this.idfile = idfile;
        this.bytes = bytes;
        this.data = data;
        this.copertina = copertina;
        this.size = size;
    }

    public Integer getIdfile() {
        return idfile;
    }

    public void setIdfile(Integer idfile) {
        this.idfile = idfile;
    }

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public boolean getCopertina() {
        return copertina;
    }

    public void setCopertina(boolean copertina) {
        this.copertina = copertina;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public Utente getUtente() {
        return utente;
    }

    public void setUtente(Utente utente) {
        this.utente = utente;
    }

    public Report getReport() {
        return report;
    }

    public void setReport(Report report) {
        this.report = report;
    }

    public Mimetype getMimetype() {
        return mimetype;
    }

    public void setMimetype(Mimetype mimetype) {
        this.mimetype = mimetype;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idfile != null ? idfile.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof File)) {
            return false;
        }
        File other = (File) object;
        if ((this.idfile == null && other.idfile != null) || (this.idfile != null && !this.idfile.equals(other.idfile))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "multiface.promonet.jpa.File[ idfile=" + idfile + " ]";
    }
    
}
